package com.fire.control.system.config.init;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.stereotype.Component;

import com.corundumstudio.socketio.SocketIOServer;
import com.fire.control.system.config.quartz.QuartzManager;
import com.fire.control.system.job.DeviceDetectionJob;
import com.fire.control.system.job.DutyDetectionJob;
import com.fire.control.system.support.util.KillServerUtil;
import com.fire.control.system.support.util.QrcodeUtil;
import com.fire.control.system.support.util.StaticValue;  

@Component  
public class InitServer implements CommandLineRunner {  
	
    @Autowired private SocketIOServer socketIOServer;
    @Autowired private QuartzManager quartzManager;
    
    @Override
    public void run(String... args) throws Exception {
    	//KillServerUtil.start(StaticValue.wss_server_port);
    	if (StringUtils.isNotEmpty(StaticValue.active)) {
    		socketIOServer.start();
		}
    	quartzManager.execute("检测设备是否离线",DeviceDetectionJob.class, StaticValue.deviceDetectionJob_cron);
    	quartzManager.execute("检测值班是否缺勤",DutyDetectionJob.class, StaticValue.dutyDetectionJob_cron);
    	
    	QrcodeUtil.createQRCodeApp();
    	
    	
    }
    
}